﻿namespace 没有async的方法
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World!");
        }

        /// <summary>
        /// 用async的方法
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        static async Task<String> ReadAsync(int num)
        {
            switch (num)
            {
                case 1:
                    return await File.ReadAllTextAsync(@"d:\test\2.txt");
                    break;
                case 2:
                    return await File.ReadAllTextAsync(@"d:\test\3.txt");
                    break;
                default:
                    throw new Exception("num invalid");
                    break;
            }
        }

        /// <summary>
        /// 不用async的方法
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        static Task<String> ReadAsync1(int num)
        {
            switch (num)
            {
                case 1:
                    return File.ReadAllTextAsync(@"d:\test\2.txt");
                    break;
                case 2:
                    return File.ReadAllTextAsync(@"d:\test\3.txt");
                    break;
                default:
                    throw new Exception("num invalid");
                    break;
            }
        }
    }
}